
import 'package:flutter/material.dart';

class ChannelPage extends StatefulWidget{

  ChannelPage({Key? key});

  @override
  State<ChannelPage> createState() => _ChannelPageState();
}

class _ChannelPageState extends State<ChannelPage> with SingleTickerProviderStateMixin  {

  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, length: 4);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Flex(
      direction: Axis.vertical,
      children: [
        TabBar(
            controller: _tabController,
            tabs: const <Tab>[
              Tab(child: Text("时钟",style: TextStyle(color: Colors.black))),
              Tab(child: Text("灯光",style: TextStyle(color: Colors.black))),
              Tab(child: Text("我的素材",style: TextStyle(color: Colors.black))),
              Tab(child: Text("设备素材",style: TextStyle(color: Colors.black))),
            ]
        ),
        Expanded(
            flex: 1,
            child: TabBarView(
              controller: _tabController,
              children: <Widget>[
                Center(
                  child: Text("It's cloudy here", style: Theme.of(context).textTheme.bodyText1),
                ),
                Center(
                  child: Text("It's rainy here", style: Theme.of(context).textTheme.bodyText1),
                ),
                Center(
                  child: Text("It's sunny here", style: Theme.of(context).textTheme.bodyText1),
                ),
                Center(
                  child: Text("It's cloudy here", style: Theme.of(context).textTheme.bodyText1),
                )
              ],
            )
        )
      ],
    );
  }

}